<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>欢迎短信</title>
  <link href="../../layui/css/layui.css" rel="stylesheet" type="text/css">
  <link href="../../css/style.css" rel="stylesheet" type="text/css">
  <script src="../../layui/layui.js"></script>
  <link href="../../layui/css/iconfont/iconfont.css" rel="stylesheet" type="text/css">
  <script src="../../layui/css/iconfont/iconfont.js"></script>
  <script src="../../js/util.js"></script>
  <script type="text/javascript">
    var wait = 60;
    function time () {
      if (wait == 0) {
        document.getElementById("send").removeAttribute("disabled");
        document.getElementById("send").value = "重新发送";
        wait = 60;
      } else {
        document.getElementById("send").setAttribute("disabled", true);
        document.getElementById("send").value = "重新发送" + wait + "s";
        wait--;
        setTimeout(function () {
          time()
        },
          1000)
      }
    }

    layui.use(['jquery', 'layer'], function () {
      var $ = layui.$;
      var layer = layui.layer;
      $('#send').on('click', function () {
        var url = '/login';
        var msisdn = $.trim($('#msisdn').val());
        var password = $.trim($('#password').val());
        var param = {
          msisdn: msisdn,
          password: password
        };
        if (isNull(msisdn)) {
          layer.msg("请输入手机号");
        } else if (isNull(password)) {
          layer("请输入密码");
        } else {
          loading = layer.load(0, { shade: false });
          $.ajax({
            type: 'post',
            data: param,
            url: url,
            success: function (json) {
              window.sessionStorage.setItem("urlStr", json.data.baiduNginxIpPort);
              if (json.code == '0') {
                $.ajax({
                  type: 'post',
                  url: "/login/sendCode?flag=login&msisdn=" + msisdn + "&password=" + password
                  , beforeSend: function () {
                    layer.close(loading);
                    time();
                  },
                  success: (function (json) {
                    layer.msg("发送成功")
                  })
                });

              } else {
                layer.close(loading);
                layer.msg("您输入的账号和密码不匹配");
              }
            }
            , error: function () {
              layer.msg('系统异常，请联系管理员处理!');
            }
          });
        }
      });
      $('#login').on('click', function () {
        var msisdn = $('#msisdn').val();
        var password = $('#password').val();
        var code = $('#code').val();
        var url = '/login/judgeMentCode?code=' + code + '&msisdn=' + msisdn + '&password=' + password;
        if (isNull(msisdn)) {
          layer.msg("请输入手机号");
        } else if (isNull(password)) {
          layer.msg("请输入密码");
        } else if (isNull(code)) {
          layer.msg("请输入验证码");
        } else {
          $.ajax({
            type: 'post',
            data: code,
            url: url,
            success: function (json) {
              if (json == "success") {
                window.location.href = "/view/index";
              } else if (json == "fail") {
                layer.msg("验证码错误");
              } else if (json == "long") {
                layer.msg("验证码超时");
              }
            }
            , error: function () {
              layer.msg('系统异常，请联系管理员处理!');
            }
          })
        }
      });

    });
  </script>
 
</head>

<body>
  <div class="login-bg">
    <!--平台名称-->
    <h4 class="login-title">欢迎名片管理平台</h4>
    <img src="../../images/logo.png" class="login-logo">
    <div class="login-icon-bg"></div>
    <!--登录页白色云层背景-->
    <div class="login-cloud-bg"></div>
    <!--登录页表单-->
    <div class="login-form">
      <h4 class="login-form-title">用户登录</h4>
      <!--登录页图标背景-->
      <div class="login-form-content-box">
        <div class="login-form-item-box">
          <i class="iconfont icon-shouji login-form-icon"></i>
          <input type="text" placeholder="手机号码" id="msisdn">
        </div>
        <div class="login-form-item-box password-form">
          <i class="iconfont icon-222yonghu_mima_yuechi2 login-form-icon"></i>
          <input type="password" placeholder="账户密码" id="password">
          <a class="forget-btn" href="/resetPwd">忘记密码</a>
        </div>
        <div class="login-form-item-inlinebox" id="getConfirm">
          <div class="login-form-item-box">
            <i class="iconfont icon-yanzhengma login-form-icon"></i>
            <input type="text" placeholder="短信验证码" id="code">
          </div>
          <input type="button" class="send-btn" id="send" value="发送验证码">
        </div>
      </div>
      <a class="login-btn" href="#" id="login">登 录</a>
    </div>
    <span class="login-footer">中国移动通信集团江苏有限公司&nbsp;&nbsp; 版权所有&nbsp;&nbsp; <a
        href="http://beian.miit.gov.cn">苏ICP备11070397号-81</a> </span>
  </div>
</body>

</html>